<template>
    <div>
        <el-select :clearable="true" v-model="topicChose" placeholder @change="getTopicModel">
            <el-option v-for="(item,index) in questionTypeList" :key="index" :label="item.message" :value="item.type"></el-option>
        </el-select>
    </div>
</template>

<script>
    import axios from "axios";
    export default {
        data() {
            return {
            topicChose: this.topicChose,
            questionTypeList: []
            };
        },
        mounted() {
            this.init();
        },
        methods: {
            init() {
                this.getTopicSelected();
            },
            //获取题目类型下拉
            getTopicSelected() {
                var that = this;
                axios
                    .get("/tes/1/1/question-repository/dropdown-list")
                    .then(function(res) {
                    console.log("成功");
                    console.log(res);
                    if (res.status === 200) {
                        if (res.data.code === 200) {
                            console.log(res.message);
                            let questionTypeList = res.data.data.questionTypeList;
                            that.questionTypeList = questionTypeList;
                            console.log(that.questionTypeList);
                        }
                    }
                    })
                    .catch(function(err) {
                        if (err.response) {
                            console.log(err.response);
                        }
                    });
            },
            getTopicModel() {
                //向父组件传值 2
                this.$emit("topicChose", this.topicChose);
            }
        }
    };
</script>
